home *** CD-ROM | disk | FTP | other *** search
- # Makefile-name: Makefile.app
- #############################################################################
- # #
- # (c) Copyright 1994 by #
- # SINTEF, Oslo, Norway. #
- # All rights reserved. #
- # #
- # See the file Copyright.h for further details. #
- # #
- #############################################################################
-
- # $Id: Makefile.app,v 1.5 1995/03/23 11:40:11 tvs Exp $
- #
- # authors: Hans Petter Langtangen and Trond Vidar Stensby, SINTEF/UiO
- #
-
- # This Makefile is intended for application programs using libraries.
- # There can only be one main program in each directory since this Makefile
- # compiles and links all .C .c and .f files in the current directory.
- # If several main programs are desireable, use the file
- # Makefile.app_1f.
-
- # **** You will seldom have to modify this file ****
-
- # All variables in this Makefile have default values that may be ok.
- # It is recommended not to edit this makefile. Instead the problem
- # dependent variables should be assigned in the user files .pdmkroot
- # (PROJECTROOT and PACKAGES) and .pdmkvars (DIRS, SRCS, etc.).
- # Both these files are included if they exist.
- #
- # A safe way of using the Makefiles is to let the script Mkdir
- # copy and customize the files.
- #
- # The items to be modified are usually the variables
- # LIBS, INCLUDEDIRS, SRCDIR, APPL, PACKAGES and PROJECTROOT.
- # LIBS contains the libraries with which the application is to be linked.
- # INCLUDEDIRS contains the directories that will be searched for
- # include files.
- # SRCDIR contains the path to the directory $(PROJECTROOT)/src.
- # If the directory containing this Makefile is a part of the $(PROJECTROOT)
- # tree, a relative path should appear in PROJECTROOT.
- # APPL is the name of the executable file after compiling and linking.
- # You may also want to include another header file for predefined
- # variables.
- #
- # The executable file is called app, by default.
- # You may prescribe app with another name by assigning the value APPL in
- # .pdmkvars
-
- # -----------------------------------------------------------------------
-
- # The MakeFlags files supports two set of makefiles:
- MakeFileVersion := NewStyle
-
- # root of present project:
- PROJECTROOT := ../../..
-
- # default is no PACKAGES
- PACKAGES :=
- TESTPACK :=
- INSTPACK :=
-
- # redefine PROJECTROOT and PACKAGES ?
-
- ifeq "$(wildcard .pdmkroot)" ".pdmkroot"
- include .pdmkroot
- endif
-
- # ----------- default values ------------
-
- # predefined gnumake variables:
-
- include $(wildcard $(PROJECTROOT)/src/MakeHeader)
-
- # Get definition of compiler flags from all packages.
- # The MakeFlags files from the different packages should be included
- # in the opposite order than listed in the variable $(PACKAGES)
-
- ifneq "$(PACKAGES)" ""
- REVERSE := $(shell reverse_args $(PACKAGES) )
- include $(foreach dir,$(REVERSE),$(wildcard $(dir)/src/MakeFlags))
- endif
-
- # include this package MakeFlags.
- include $(wildcard $(PROJECTROOT)/src/MakeFlags)
-
- # directories containing the files to be compiled (can be overrided):
-
- DIRS :=
-
- # the name of the executable file after compiling and linking.
- APPL := app
-
- # the source files are all the .C, .c and .f files in current directory
- # and the files in the directories in DIRS:
- SRCS := $(wildcard ./*.[Ccf])
-
- # all *.C files make up the library (sometimes the user overrides the SRCS
- # variable - e.g. for compiling a single file - and then ALLSRCS indicates
- # the files that should enter the library):
-
- ALLSRCS := $(wildcard ./*.[Ccf])
-
- # the tilde files (to be removed by clean):
- TILD := $(wildcard ./*~)
-
- # ----------- redefine problem dependent variables ------------
-
- ifeq "$(wildcard .pdmkvars)" ".pdmkvars"
- include $(wildcard .pdmkvars)
- endif
-
- #------------ the below statements should not be modified ----------------
-
- # the source files are all the .C, .c and .f files in current directory
- # and the files in the directories in DIRS:
- SRCS := $(SRCS) $(foreach dir,$(DIRS),$(wildcard $(dir)/*.[Ccf]))
-
- # all *.C files make up the library (sometimes the user overrides the SRCS
- # variable - e.g. for compiling a single file - and then ALLSRCS indicates
- # the files that should enter the library):
-
- ALLSRCS := $(ALLSRCS) $(foreach dir,$(DIRS),$(wildcard $(dir)/*.[Ccf]))
-
- # the tilde files (to be removed by clean):
- TILD := $(TILD) $(foreach dir,$(DIRS),$(wildcard $(dir)/*~))
-
- # remove multiple entries
-
- SRCS := $(sort $(SRCS))
- ALLSRCS := $(sort $(ALLSRCS))
- TILD := $(sort $(TILD))
-
- ifeq ($(LINKLEVEL),install)
- PACKDIR := $(shell add_suffix "$(PACKAGES)" "/src" "$(TESTPACK)")
- else
- TP := $(shell remove_elem "$(PACKAGES)" "$(INSTPACK)")
- ifneq "$(TP)" ""
- PACKDIR :=$(shell add_suffix "$(PACKAGES)" "/src" "$(TP)")
- else
- PACKDIR := $(PACKAGES)
- endif
- endif
-
- ifeq ($(LINKLEVEL),install)
- INCLUDEDIRS := $(foreach dir,$(DIRS),-I$(dir)) \
- $(INCLUDEDIRS) -I$(PROJECTROOT)/include \
- $(foreach pack,$(PACKDIR),-I$(pack)/include)
-
- else
- INCLUDEDIRS := $(foreach dir,$(DIRS),-I$(dir)) \
- $(INCLUDEDIRS) -I$(PROJECTROOT)/src/include \
- $(foreach pack,$(PACKDIR),-I$(pack)/include)
- endif
-
- # file for results from verification procedures (test problems):
- VERIFYLOG := $(PWD)/verify.log
-
-
- #-----------------------------------------------------------------------
- # the application is dependent on libraries in the following directories:
- #-----------------------------------------------------------------------
-
- # LDPATH contains the directories where ld search for libraries, these
- # directories depend on the LINKLEVEL variable (value equal to install or
- # test). LINKLEVEL=test means that programs are linked to libraries in the
- # test version, while LINKLEVEL=install means that one links to installed
- # libraries.
-
- ifeq ($(LINKLEVEL),install)
- # VPATH should contain the same directories as LDPATH
- # if there are error messages like "No way to make -ltop", VPATH may
- # be wrong. It may help putting all parts of LDPATH on the same line,
- # or use := assignment and no \ extension of lines!
-
- LDPATH := $(LDPATH) -L$(PROJECTROOT)/lib/$(LIBTYPE)/$(EXT)\
- $(foreach pack,$(PACKDIR),-L$(pack)/lib/$(LIBTYPE)/$(EXT))
-
- else # test version of libraries (search in /src - directories first):
-
- LDPATH := $(LDPATH) -L$(PROJECTROOT)/src/lib/$(LIBTYPE)/$(EXT)\
- $(foreach pack,$(PACKDIR), -L$(pack)/lib/$(LIBTYPE)/$(EXT))
- endif
-
- # VPATH should contain the same directories as LDPATH
- VPATH := $(patsubst -L%,:%,$(LDPATH))
- VPATH := $(patsubst -I%,:%,$(VPATH))
- VPATH := $(subst $(empty) :,:,$(strip $(VPATH)))
-
- # Only normal (*.a) libraries kan be a part of the dependencies
- ifneq ($(SHARED),on)
- DEPLIBS := $(LIBS) $(SYSLIBS)
- else
- DEPLIBS :=
- endif
-
- # let the object files be the *.[Ccf] files but with .[Ccf] replaced by .o:
-
- OBJS := $(SRCS:.C=.o)
- OBJS := $(OBJS:.c=.o)
- OBJS := $(OBJS:.f=.o)
-
- OBJS := $(foreach obj,$(OBJS),$(PREFIX)$(obj))
-
- # ALLOBJS is used when linking, ALLSRCS is used to make ALLOBJS
- ALLOBJS := $(subst .C,.o,$(ALLSRCS))
- ALLOBJS := $(subst .c,.o,$(ALLOBJS))
- ALLOBJS := $(subst .f,.o,$(ALLOBJS))
-
- ALLOBJS := $(foreach obj,$(ALLOBJS),$(PREFIX)$(obj))
-
- # dependencies for make depend should be equal to all object files, but
- # with .o suffix replaced with .d
-
- DEPFILES := $(OBJS:.o=.d)
-
- # Make dependencies invisible
-
- ifeq ("$(OUTPUT)","INVISIBLE")
- DEPFILES := $(foreach file,$(DEPFILES),$(dir $(file)).$(notdir $(file)))
- endif
-
- # preprocessor files should be equal to all object files, but
- # with .o suffix replaced with .E
-
- PREPROFILES := $(OBJS:.o=.E)
-
- # Check that *.o files are of the right type
- $(shell newcomptype "$(PREFIX)" "$(LIBTYPE)" \
- "$(CXXFLAGS) $(CCFLAGS) $(FFLAGS) $(LDFLAGS)" "$(OBJS)")
-
- include $(wildcard $(PROJECTROOT)/src/MakeRules)
-
- # Rules for making the application, and rules for clean. depend, ...
- #
- #-----------------------------------------------------------------------------
-
- all: $(APPL)
- @echo
- @echo "---------- application \"$(APPL)\" done ----------"
-
-
- $(APPL): $(OBJS) $(DEPLIBS)
- @echo
- @echo
- @echo "---------- linking $(OBJS) ----------"
- @echo
- @echo
- $(LD) $(LDFLAGS) -o $@ $(ALLOBJS) $(LIBS) $(SYSLIBS)
- ifeq ("$(INSTALL_EXE)","yes")
- @mkdirhier $(PROJECTROOT)/bin/$(LIBTYPE)/$(EXT)
- @mv $@ tmp
- @mv tmp $(PROJECTROOT)/bin/$(LIBTYPE)/$(EXT)/$@
- @echo "\n`ls -l $(PROJECTROOT)/bin/$(LIBTYPE)/$(EXT)/$@ | \
- awk '{print $$5, $$6, $$7, $$8, $$9}'`" ;
- endif
-
- clean:
- @echo removing `ls -s $(OBJS) $(TILD) $(APPL) $(PREPROFILES) core *.bak SIMULATION.* .SIMULATION* 2> /dev/null`
- @rm -f $(OBJS) $(TILD) $(APPL) $(PREPROFILES) core *.bak SIMULATION.* .SIMULATION*
-
- cleanex:
- rm -f $(TILD) $(APPL) core *.bak
- rm -f $(PROJECTROOT)/bin/$(LIBTYPE)/$(EXT)/$(APPL)
-
- clobber:
- @echo removing `ls -s $(ALLOBJS) $(DEPFILES) $(TILD) $(APPL) core *.bak SIMULATION.* .SIMULATION* .comptype 2> /dev/null`
- @rm -f $(OBJS) $(DEPFILES) $(TILD) $(APPL) core *.bak SIMULATION.* .SIMULATION* .comptype
-
- depend: $(DEPFILES)
- @echo
- @echo "---------- Dependencies done ----------"
-
- headercp:
- @echo
- @echo "---------- No headercp in application dir ----------"
-
- newverify:
- @echo
- @echo "In directory `pwd`"
- @echo Results from last verification registered as reference.
- @NewVerify
-
- prepro: $(PREPROFILES)
- @echo
- @echo "---------- Preprocessing done ----------"
-
- removelib:
- @echo
- @echo "---------- No removelib in application dir ----------"
-
- verifyall: all verify clean
-
- verify:
- @echo
- @echo "Using input in `pwd`"
- @echo "(Results in $(VERIFYLOG))"
- ifeq ($(MAKELEVEL),0)
- @rm -f verify.log ; touch verify.log
- endif
- @echo "Verifications run on $$HOSTTYPE\n\n\n" >> $(VERIFYLOG)
- @Verify $(VERIFYLOG)
-
- # Include dependencies.
-
- ifneq "$(foreach file,$(DEPFILES),$(wildcard $(file)))" ""
- include $(foreach file,$(DEPFILES),$(wildcard $(file)))
- endif
-